package com.fzhucc.modules.timer;


import com.fzhucc.modules.dataModel.service.DataModelService
import com.fzhucc.modules.sciPersonnelInfo.service.SciPersonnelInfoService
import org.slf4j.LoggerFactory
import org.springframework.beans.factory.annotation.Value
import org.springframework.scheduling.annotation.Scheduled
import org.springframework.stereotype.Component
import org.springframework.transaction.annotation.Transactional

@Component
class TimerWorkTask(
    private val sciPersonnelInfoService: SciPersonnelInfoService,
    private val dataModelService: DataModelService
) {
    @Value("\${dj.is.send}")
    lateinit var send: String

    @Value("\${dj.is.run}")
    lateinit var run: String

    companion object {
        private val logger = LoggerFactory.getLogger(TimerWorkTask::class.java)
    }


    //每周一早上9点执行
    @Scheduled(cron = "0 0 9 ? * MON")
    @Transactional
    fun doSendData() {
        if (send.equals("1")) {
            sciPersonnelInfoService.getZnTestSendSingle()
        }
    }

    //每周一早上10点执行
    @Scheduled(cron = "0 0 10 ? * MON")
    @Transactional
    fun doSendData2() {
        if (send.equals("1")) {
            sciPersonnelInfoService.getZnTest2SendSingle()
        }
    }

    //发送特定数据
    /*@Scheduled(cron = "0 0 17 ? * MON")
    @Transactional
    fun doSendDataTd() {
        if (send.equals("1")) {
            sciPersonnelInfoService.getZnTestSendSingleTd()
        }
    }*/


    //每天0点1分执行 计算前日数据
    @Scheduled(cron = "0 01 0 * * ?")
    fun doSaveBigData() {
        if (run.equals("1")) {
            dataModelService.doSaveBigData()
        }
    }
}